﻿using System;
using System.Collections;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            ht.Add(1,"计算机基础");
            ht.Add(2, "C#高级编程");
            ht.Add(3, "数据库应用");
            Console.WriteLine("请输入图书编号");
            int id = int.Parse(Console.ReadLine());
            bool flag = ht.ContainsKey(id);
            if (flag)
            {
                Console.WriteLine("你要查找的图书名称为：{0}",ht[id].ToString());
            }
            else
            {
                Console.WriteLine("你要查找的图书不存在！");
            }
            Console.WriteLine("所有图书信息如下：");
            foreach(DictionaryEntry d in ht)
            {
                int key = (int)d.Key;
                string value = d.Value.ToString();
                Console.WriteLine("图书编号：{0}     图书名称：{1}",key,value);
            }
        }
    }
}
